<?php

class by extends a_front_controller{
    protected $srv;
    protected $products;
    protected $count;
    protected $page_link;
    public function  __construct($post_handling_enabled = FALSE) {
        parent::__construct($post_handling_enabled);
        $this->srv = new service_l_search();
    }
    public function category($id,$page=1,$limit=10){
//        $cat_id = xss_clean($id);
//        $main_param = new main_product_search_param("m");
//        $processor  = new search_processor_l_search("PRODUCTS", $main_param);
//        $processor->add_params(new join_product_category("ct", $cat_id));
//        $this->srv->process_url_params($processor);
    }

    public function part_num_desc($offset=0){

        $offset = starts_with($offset,"p~" ) ? 0: $offset;
        $processor  = new search_processor_l_search("PRODUCTS",TRUE);

        $param = new dynamic_param_l_search(microtime(), module_u_search::SEARCH_TYPE_PARAM );
        $param->set_where_line("(products.publish = 1 AND products.is_deleted = 0)");
        $param->set_select_line("DISTINCT(part_num),products.*");
        $processor->add_param($param);

        $url_params = $processor->add_params_from_url();
        $url_tail = regenerate_url_for_paging($url_params);

        $this->count = $processor->count_result();        
        $this->page_link = get_pagigination("search/by/part_num_desc/", $this->count,  module_u_search::DEFAULT_PER_PAGE,$url_tail);
        $this->products = $processor->get_result(new product_m_product(),$offset,  module_u_search::DEFAULT_PER_PAGE);
        
        
    }

    public function  batch_assign() {
        $this->assign("products", $this->products);
        $this->assign("count", $this->count); 
        $this->assign("page_link", $this->page_link);
    }

}
?>
